package com.itwill.ecom.boardQnAReply;

import java.util.List;

import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository("boardQnAReplyService")
public class BoardQnAReplyServiceImpl implements BoardQnAReplyService{
	
	/////객체 생성 및 생성자,set,get/////
	@Autowired
	private BoardQnAReplyDao boardQnAReplyDao;
	
	public BoardQnAReplyServiceImpl() {
		System.out.println("BoardQnAServiceImpl() 생성");
	}

	public BoardQnAReplyServiceImpl(BoardQnAReplyDao boardQnAReplyDao) {
		
		this.boardQnAReplyDao = boardQnAReplyDao;
	}

	public BoardQnAReplyDao getBoardQnAReplyDao() {
		return boardQnAReplyDao;
	}
 
	
	public void setBoardQnAReplyDao(BoardQnAReplyDao boardQnAReplyDao) {
		this.boardQnAReplyDao = boardQnAReplyDao;
	}

	//// 게시글 작성 ////
	@Override
	public int createBoardQnAReply(BoardQnAReplyBeans boardQnAReplyBeans) {
		int result=-1;
		try{
			result=boardQnAReplyDao.createBoardQnAReply(boardQnAReplyBeans);
			result=1;
		}catch(Exception e){
			String msg=e.getMessage();
			System.out.println(msg);
			
		}
		return result;
	}
	
	//// 게시글 모두 호출 ////
	@Override
	public List<BoardQnAReplyBeans> getAllBoardQnAReply() {
		List<BoardQnAReplyBeans> selectQnABoardReply = null;
		try{
		selectQnABoardReply=boardQnAReplyDao.getAllBoardQnAReply();
		}catch(Exception e){
			String msg=e.getMessage();
			System.out.println(msg);
			
		}
		return selectQnABoardReply;
	}

	//// 내 게시물 검색 ////
	@Override
	public List<BoardQnAReplyBeans> getByIdBoardQnAReply(String qnaboard_reply_id) {
		List<BoardQnAReplyBeans> selectMyQnABoardReply=null;
		try{
			selectMyQnABoardReply=boardQnAReplyDao.getById(qnaboard_reply_id);
		}catch(Exception e){
			String msg=e.getMessage();
			System.out.println(msg);
		}
		return selectMyQnABoardReply;
	}
	
	//// 게시글 수정 ////
	@Override
	public int updateBoardQnAReply(BoardQnAReplyBeans boardQnAReplyBeans) {
		int result= -1;
		try{
			result=boardQnAReplyDao.updateBoardQnAReply(boardQnAReplyBeans);
			result=1;
		}catch(Exception e){
			String msg=e.getMessage();
			System.out.println(msg);
		}
		return result;
	}
	
	//// 게시글 삭제 ////
	@Override
	public int deleteBoardQnAReply(int qnaboard_reply_no) {
		int result=-1;
		try{
			result=boardQnAReplyDao.deleteBoardQnAReply(qnaboard_reply_no);
		}catch(Exception e){
			String msg=e.getMessage();
			System.out.println(msg);
		}
		return result;
	}
	//// 해당 글의 댓글을 검색하는 메서드 ////
	@Override
	public List<BoardQnAReplyBeans> getByNoBoardQnAReply(int qnaboard_reply_group) {
		List<BoardQnAReplyBeans> qnaboard = null;
		
		try{
		
		qnaboard=boardQnAReplyDao.getByNo(qnaboard_reply_group);
		
		}catch(Exception e){
			e.printStackTrace();
		
		}
		
		return qnaboard;
		
	}
	
	
	

}
